﻿Imports VN.INS.DL.DH
Imports VN.INS.BL.BE

Public Class FisicoDA
    Public Function filtrar_fisico(ByVal poa As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = " SELECT FP.ESTADO," + _
                      " PE.MES," + _
                      " PE.DESCRIPCION AS PERIODO," + _
                      " PE.ANHIO," + _
                      " PTP.ID_PLAN_TRABAJO_POA," + _
                      " PAF.ID_POA_ACTIVIDAD_FISICA," + _
                      " TAREA_ACTIVIDAD_DESCRIPCION AS TAREA_ACTIVIDAD," + _
                      " D.DESCRIPCION," + _
                      " (  NVL (META_01, 0)" + _
                      " + NVL (META_02, 0)" + _
                      " + NVL (META_03, 0)" + _
                      " + NVL (META_04, 0)" + _
                      " + NVL (META_05, 0)" + _
                      " + NVL (META_06, 0)" + _
                      " + NVL (META_07, 0)" + _
                      " + NVL (META_08, 0)" + _
                      " + NVL (META_09, 0)" + _
                      " + NVL (META_10, 0)" + _
                      " + NVL (META_11, 0)" + _
                      " + NVL (META_12, 0))" + _
                      " AS META_ANUAL," + _
                      " CASE PE.MES" + _
                      " WHEN '01' THEN META_01" + _
                      " WHEN '02' THEN META_02" + _
                      " WHEN '03' THEN META_03" + _
                      " WHEN '04' THEN META_04" + _
                      " WHEN '05' THEN META_05" + _
                      " WHEN '06' THEN META_06" + _
                      " WHEN '07' THEN META_07" + _
                      " WHEN '08' THEN META_08" + _
                      " WHEN '09' THEN META_09" + _
                      " WHEN '10' THEN META_10" + _
                      " WHEN '11' THEN META_11" + _
                      " WHEN '12' THEN META_12" + _
                      " End" + _
                      " AS MES1," + _
                      " (CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 1 THEN NVL (META_01, 0)" + _
                      " ELSE 0" + _
                      " End" + _
                      " + CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 2 THEN NVL (META_02, 0)" + _
                      " ELSE 0" + _
                      " End" + _
                      " + CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 3 THEN NVL (META_03, 0)" + _
                      " ELSE 0 " + _
                      " End " + _
                      " + CASE " + _
                      " WHEN TO_NUMBER (PE.MES) >= 4 THEN NVL (META_04, 0)" + _
                      " ELSE 0" + _
                      " End" + _
                      " + CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 5 THEN NVL (META_05, 0)" + _
                      " ELSE 0" + _
                      " End" + _
                      " + CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 6 THEN NVL (META_06, 0)" + _
                      " ELSE 0" + _
                      " End" + _
                      " + CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 7 THEN NVL (META_07, 0)" + _
                      " ELSE 0" + _
                      " End" + _
                      " + CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 8 THEN NVL (META_08, 0)" + _
                      " ELSE 0" + _
                      " End" + _
                      " + CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 9 THEN NVL (META_09, 0)" + _
                      " ELSE 0" + _
                      " End" + _
                      " + CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 10 THEN NVL (META_10, 0)" + _
                      " ELSE 0" + _
                      " End" + _
                      " + CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 11 THEN NVL (META_11, 0)" + _
                      " ELSE 0" + _
                      " End" + _
                      " + CASE" + _
                      " WHEN TO_NUMBER (PE.MES) >= 12 THEN NVL (META_12, 0)" + _
                      " ELSE 0" + _
                      " END)" + _
                      " AS ACUMULADO," + _
                      " FP.META_MENSUAL1," + _
                      " FP.META_MENSUAL2," + _
                      " FP.META_MENSUAL3," + _
                      " NVL2(FP.META_MENSUAL4, FP.META_MENSUAL4, 0) META_MENSUAL4," + _
                      " FP.FECHA_VISITA1," + _
                      " FP.FECHA_VISITA2," + _
                      " FP.FECHA_VISITA3," + _
                      " FP.FECHA_VISITA4, " + _
                      " FP.OBSERVACIONES," + _
                      " FP.ID_POA_FISICO_PERSONA" + _
                      " FROM POA_ACTIVIDAD_FISICA PAF" + _
                      " INNER JOIN UNIDAD D" + _
                      " ON PAF.UNIDAD = D.UNIDAD " + _
                      " INNER JOIN POA P" + _
                      " ON P.POA = PAF.POA " + _
                      " INNER JOIN PLAN_TRABAJO_POA PTP" + _
                      " ON PTP.POA = P.POA " + _
                      " INNER JOIN PLAN_TRABAJO_PERSONA PTPE" + _
                      " ON PTPE.ID_PLAN_TRABAJO_PERSONA = PTP.ID_PLAN_TRABAJO_PERSONA" + _
                      " INNER JOIN PERIODO PE" + _
                      " ON PE.PERIODO = PTPE.PERIODO " + _
                      " LEFT JOIN POA_FISICO_PERSONA FP" + _
                      " ON FP.ID_PLAN_TRABAJO_POA = PTP.ID_PLAN_TRABAJO_POA AND FP.ID_POA_ACTIVIDAD_FISICA = PAF.ID_POA_ACTIVIDAD_FISICA" + _
                      " WHERE P.POA = '" & poa & "'" + _
                      " ORDER BY FP.ID_POA_FISICO_PERSONA ,PAF.ID_POA_ACTIVIDAD_FISICA "
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function

    Public Function verifica_accion(ByVal srtPoa As String, ByVal strPeriodo As String) As Integer
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim NUMERO As Integer
        Dim lxc_SQL As String

        Try

            lxc_SQL = " SELECT * FROM POA_FISICO_PERSONA " + _
                    " WHERE POA_FISICO_PERSONA.ID_PLAN_TRABAJO_POA =( " + _
                    " SELECT ID_PLAN_TRABAJO_POA FROM PLAN_TRABAJO_POA INNER JOIN PLAN_TRABAJO_PERSONA  " + _
                    " ON PLAN_TRABAJO_POA.ID_PLAN_TRABAJO_PERSONA = PLAN_TRABAJO_PERSONA.ID_PLAN_TRABAJO_PERSONA  " + _
                    " INNER JOIN  PERIODO ON PLAN_TRABAJO_PERSONA.PERIODO = PERIODO.PERIODO  " + _
                    " WHERE PLAN_TRABAJO_POA.POA='" + srtPoa + "' AND PERIODO.PERIODO= '" + strPeriodo + "') "
            'PERIODO.MES = (select to_char(sysdate,'MM') from dual) AND
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            NUMERO = objDt.Rows.Count

            Return NUMERO

        Catch ex As Exception
            Throw
        End Try
    End Function

    Public Sub insertar_fisico_per(ByVal IDPOACT As String, ByVal EJEC_M As String, ByVal MTM1 As String, ByVal MTM2 As String, ByVal MTM3 As String, ByVal MTM4 As String, ByVal IDFPER As String, ByVal IDPLAN As String, ByVal OB As String, ByVal F1 As String, ByVal F2 As String, ByVal F3 As String, ByVal F4 As String, ByVal E As String, ByVal strVersion As String)
        Dim objData As AdministradorOracle = New AdministradorOracle

        Try
            objData.CreateInputOracle("IDPOACT", IDPOACT, 20)
            objData.CreateInputOracle("F1", F1, 20)
            objData.CreateInputOracle("F2", F2, 20)
            objData.CreateInputOracle("F3", F3, 20)
            objData.CreateInputOracle("F4", F4, 20)
            objData.CreateInputOracle("EJEC_M", EJEC_M, 20)
            objData.CreateInputOracle("MTM1", MTM1, 20)
            objData.CreateInputOracle("MTM2", MTM2, 20)
            objData.CreateInputOracle("MTM3", MTM3, 20)
            objData.CreateInputOracle("MTM4", MTM4, 20)
            objData.CreateInputOracle("IDFPER", IDFPER, 20)
            objData.CreateInputOracle("IDPLAN", IDPLAN, 20)
            objData.CreateInputOracle("OB", OB, 1000)
            objData.CreateInputOracle("E", E, 1)
            objData.CreateInputOracle("VERSION", strVersion, 1)
            objData.ExecuteOracle_NonQuery("INSERTARFISICOPERSONA", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    'Esta función fue modificada por Tigrito el 21/08... para añadir la columnas de calculo auxiliares
    'Pero no era necesario modificar el query... ya que se puede hacer tal como se hizo con el financiero
    'osea solo trabajando con las columnas...
    'Hay que regresar el query a la versión del 20/08/2013
    Public Function editar_fisico(ByVal strPoa As String, ByVal strPeriodo As String, ByVal strVersion As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Dim strCadAuxi As String
        Dim strCadAuxiEspecial As String

        Try
            If strPeriodo = "201306" Then
                strCadAuxi = " NVL2(EJEC_EN_EL_MES,EJEC_EN_EL_MES, '') "

                strCadAuxiEspecial = "  (CASE WHEN TO_NUMBER(PERIODO.MES) >= 1 THEN NVL(META_01,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 2 THEN NVL(META_02,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 3 THEN NVL(META_03,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 4 THEN NVL(META_04,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 5 THEN NVL(META_05,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 6 THEN NVL(META_06,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 7 THEN NVL(META_07,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 8 THEN NVL(META_08,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 9 THEN NVL(META_09,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 10 THEN NVL(META_10,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 11 THEN NVL(META_11,0) ELSE 0 END + " + _
                                        " CASE WHEN TO_NUMBER(PERIODO.MES) >= 12 THEN NVL(META_12,0) ELSE 0 END " + _
                                       "  )  "
            Else
                strCadAuxi = " NVL(OBT_FIS_ACUM_MES_ANT(POA_HISTORICO.POA, PERIODO.PERIODO ,POA_FISICA_HISTORICO.ID_POA_ACTIVIDAD_FISICA, '" + strVersion + "'),0) "

                If strPeriodo = "201401" Then
                    strCadAuxiEspecial = " ( NVL(META_01,0) + NVL(META_02,0) + NVL(META_03,0) + NVL(META_04,0) + NVL(META_05,0) + NVL(META_06,0) + NVL(META_07,0) + NVL(META_08,0) + NVL(META_09,0) + NVL(META_10,0) + NVL(META_11,0) + NVL(META_12,0) ) "
                Else

                    strCadAuxiEspecial = "  (CASE WHEN TO_NUMBER(PERIODO.MES) >= 1 THEN NVL(META_01,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 2 THEN NVL(META_02,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 3 THEN NVL(META_03,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 4 THEN NVL(META_04,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 5 THEN NVL(META_05,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 6 THEN NVL(META_06,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 7 THEN NVL(META_07,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 8 THEN NVL(META_08,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 9 THEN NVL(META_09,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 10 THEN NVL(META_10,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 11 THEN NVL(META_11,0) ELSE 0 END + " + _
                                            " CASE WHEN TO_NUMBER(PERIODO.MES) >= 12 THEN NVL(META_12,0) ELSE 0 END " + _
                                           "  )  "
                End If

            End If

            lxc_SQL = "  SELECT POA_FISICA_HISTORICO.CODIGO, POA_FISICO_PERSONA.ESTADO,PERIODO.DESCRIPCION AS PERIODO ,PERIODO.MES,PERIODO.ANHIO, PLAN_TRABAJO_POA.ID_PLAN_TRABAJO_POA , POA_FISICA_HISTORICO.ID_POA_ACTIVIDAD_FISICA ,  ID_POA_FISICO_PERSONA,TAREA_ACTIVIDAD_DESCRIPCION AS TAREA_ACTIVIDAD,D.DESCRIPCION," + _
               " " + strCadAuxi + " EJEC_EN_EL_MES,   ( NVL(META_01, 0) +  NVL(META_02, 0) + NVL(META_03, 0) + NVL(META_04, 0) + NVL(META_05, 0) +NVL(META_06, 0) +" + _
            " NVL(META_07, 0)  + NVL(META_08, 0) + NVL(META_09, 0) + NVL(META_10, 0) +NVL(META_11, 0) +  NVL(META_12,0) ) AS META_ANUAL, " + _
             " CASE PERIODO.MES " + _
            "  WHEN '01' THEN META_01 " + _
             " WHEN '02' THEN META_02 " + _
             " WHEN '03' THEN META_03 " + _
             " WHEN '04' THEN META_04 " + _
             " WHEN '05' THEN META_05 " + _
             " WHEN '06' THEN META_06 " + _
             " WHEN '07' THEN META_07 " + _
             " WHEN '08' THEN META_08 " + _
             " WHEN '09' THEN META_09 " + _
             " WHEN '10' THEN META_10 " + _
             " WHEN '11' THEN META_11 " + _
             " WHEN '12' THEN META_12 " + _
             " END AS MES1  " + _
             " ," + strCadAuxiEspecial + " AS ACUMULADO, " + _
             " NVL2(POA_FISICO_PERSONA.META_MENSUAL1, POA_FISICO_PERSONA.META_MENSUAL1, 0) META_MENSUAL1, " + _
             " NVL2(POA_FISICO_PERSONA.META_MENSUAL2, POA_FISICO_PERSONA.META_MENSUAL2, 0) META_MENSUAL2, " + _
             " NVL2(POA_FISICO_PERSONA.META_MENSUAL3, POA_FISICO_PERSONA.META_MENSUAL3, 0) META_MENSUAL3, " + _
            "  NVL2(POA_FISICO_PERSONA.META_MENSUAL4, POA_FISICO_PERSONA.META_MENSUAL4, 0) META_MENSUAL4,   " + _
             " POA_FISICO_PERSONA.OBSERVACIONES,POA_FISICO_PERSONA.FECHA_VISITA1,POA_FISICO_PERSONA.FECHA_VISITA2,POA_FISICO_PERSONA.FECHA_VISITA3,POA_FISICO_PERSONA.FECHA_VISITA4, " + _
             " ( " + _
             " (CASE WHEN FECHA_VISITA4 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL4, POA_FISICO_PERSONA.META_MENSUAL4, 0)  ELSE " + _
                    " (CASE WHEN FECHA_VISITA3 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL3, POA_FISICO_PERSONA.META_MENSUAL3, 0)  ELSE " + _
                    " (CASE WHEN FECHA_VISITA2 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL2, POA_FISICO_PERSONA.META_MENSUAL2, 0)  ELSE " + _
                    " NVL2(POA_FISICO_PERSONA.META_MENSUAL1, POA_FISICO_PERSONA.META_MENSUAL1, 0)  END)END)END) " + _
              "- " + _
              " " + strCadAuxi + "  " + _
              " ) EJEC_PRESENTE_MES, " + _
               "  DIV_POR_CERO ( " + _
                "  ( " + _
                "  CASE WHEN FECHA_VISITA4 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL4, POA_FISICO_PERSONA.META_MENSUAL4, 0)  ELSE " + _
                        " (CASE WHEN FECHA_VISITA3 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL3, POA_FISICO_PERSONA.META_MENSUAL3, 0)  ELSE  " + _
                        "(CASE WHEN FECHA_VISITA2 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL2, POA_FISICO_PERSONA.META_MENSUAL2, 0)  ELSE " + _
                        "NVL2(POA_FISICO_PERSONA.META_MENSUAL1, POA_FISICO_PERSONA.META_MENSUAL1, 0)  END)END)END) " + _
                 " - " + _
                  " " + strCadAuxi + " " + _
                   " , " + _
                "( " + _
                  "CASE PERIODO.MES " + _
                      "WHEN '01' THEN META_01 " + _
                      "WHEN '02' THEN META_02 " + _
                      "WHEN '03' THEN META_03 " + _
                      "WHEN '04' THEN META_04 " + _
                      "WHEN '05' THEN META_05  " + _
                      "WHEN '06' THEN META_06 " + _
                      "WHEN '07' THEN META_07 " + _
                      "WHEN '08' THEN META_08 " + _
                      "WHEN '09' THEN META_09 " + _
                      "WHEN '10' THEN META_10  " + _
                      "WHEN '11' THEN META_11 " + _
                      "WHEN '12' THEN META_12 " + _
                  "END " + _
                  ") " + _
               ") PORC_EJEC_PRESENTE_MES, " + _
              "(CASE WHEN FECHA_VISITA4 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL4, POA_FISICO_PERSONA.META_MENSUAL4, 0)  ELSE " + _
                     "(CASE WHEN FECHA_VISITA3 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL3, POA_FISICO_PERSONA.META_MENSUAL3, 0)  ELSE " + _
                     "(CASE WHEN FECHA_VISITA2 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL2, POA_FISICO_PERSONA.META_MENSUAL2, 0)  ELSE " + _
                     "NVL2(POA_FISICO_PERSONA.META_MENSUAL1, POA_FISICO_PERSONA.META_MENSUAL1, 0)  END)END)END) EJEC_ACUM_PRESENTE_MES, " + _
              "DIV_POR_CERO( " + _
                  "(CASE WHEN FECHA_VISITA4 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL4, POA_FISICO_PERSONA.META_MENSUAL4, 0)  ELSE " + _
                        "(CASE WHEN FECHA_VISITA3 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL3, POA_FISICO_PERSONA.META_MENSUAL3, 0)  ELSE " + _
                         "(CASE WHEN FECHA_VISITA2 IS NOT NULL THEN NVL2(POA_FISICO_PERSONA.META_MENSUAL2, POA_FISICO_PERSONA.META_MENSUAL2, 0)  ELSE " + _
                         "NVL2(POA_FISICO_PERSONA.META_MENSUAL1, POA_FISICO_PERSONA.META_MENSUAL1, 0)  END)END)END) , " + _
                  " " + strCadAuxiEspecial + " " + _
             " )   PORC_EJEC_ACUM_PRESENTE_MES " + _
             "      FROM POA_FISICA_HISTORICO " + _
             "      INNER JOIN UNIDAD D " + _
             "      ON POA_FISICA_HISTORICO.UNIDAD = D.UNIDAD " + _
             "      INNER JOIN POA_HISTORICO " + _
             "      ON POA_HISTORICO.POA = POA_FISICA_HISTORICO.POA " + _
             "      INNER JOIN PLAN_TRABAJO_POA " + _
             "      ON POA_FISICA_HISTORICO.POA = PLAN_TRABAJO_POA.POA  " + _
             "      INNER JOIN PLAN_TRABAJO_PERSONA " + _
             "      ON PLAN_TRABAJO_POA.ID_PLAN_TRABAJO_PERSONA = PLAN_TRABAJO_PERSONA.ID_PLAN_TRABAJO_PERSONA " + _
             "      INNER JOIN PERIODO " + _
             "      ON PLAN_TRABAJO_PERSONA.PERIODO = PERIODO.PERIODO " + _
             "      LEFT JOIN POA_FISICO_PERSONA " + _
             "      ON POA_FISICO_PERSONA.ID_POA_ACTIVIDAD_FISICA = POA_FISICA_HISTORICO.ID_POA_ACTIVIDAD_FISICA " + _
             "      AND POA_FISICO_PERSONA.ID_PLAN_TRABAJO_POA =  PLAN_TRABAJO_POA.ID_PLAN_TRABAJO_POA " + _
             " WHERE POA_HISTORICO.POA =  '" + strPoa + "' AND  " + _
                    "POA_HISTORICO.VERSION = '" + strVersion + "' AND " + _
                    "POA_FISICA_HISTORICO.VERSION = '" + strVersion + "' "

            If strPeriodo <> "all" Then
                lxc_SQL = lxc_SQL & "AND  PERIODO.PERIODO ='" & strPeriodo & "' "
            Else
                lxc_SQL = lxc_SQL & " AND PERIODO.MES = (select to_char(sysdate,'MM') FROM DUAL)"
            End If
            'By Tigrito (05/06/2013): Commented
            'lxc_SQL = lxc_SQL & " ORDER BY TAREA_ACTIVIDAD, POA_FISICO_PERSONA.ID_POA_FISICO_PERSONA "
            'By Tigrito (18/06/2013): Solucionó el problema del orden =)
            lxc_SQL = lxc_SQL & "ORDER BY " + _
                                " TO_NUMBER(NVL2(REGEXP_SUBSTR(CODIGO,'[^._]+',1,1), REGEXP_SUBSTR(CODIGO,'[^._]+',1,1), 0)) ASC, " + _
                                " TO_NUMBER(NVL2(REGEXP_SUBSTR(CODIGO,'[^._]+',1,2), REGEXP_SUBSTR(CODIGO,'[^._]+',1,2), 0)) ASC, " + _
                                " TO_NUMBER(NVL2(REGEXP_SUBSTR(CODIGO,'[^._]+',1,3), REGEXP_SUBSTR(CODIGO,'[^._]+',1,3), 0)) ASC, " + _
                                " TO_NUMBER(NVL2(REGEXP_SUBSTR(CODIGO,'[^._]+',1,4), REGEXP_SUBSTR(CODIGO,'[^._]+',1,4), 0)) ASC, " + _
                                " TO_NUMBER(NVL2(REGEXP_SUBSTR(CODIGO,'[^._]+',1,5), REGEXP_SUBSTR(CODIGO,'[^._]+',1,5), 0)) ASC "
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function

    Public Sub edicion_grilla(ByVal strEjec_M As String, ByVal strM1 As String, ByVal strM2 As String, ByVal strM3 As String, ByVal strM4 As String, ByVal strCodigo As String, ByVal OB As String, ByVal F1 As String, ByVal F2 As String, ByVal F3 As String, ByVal F4 As String, ByVal E As String, ByVal strVersion As String)
        Dim objData As AdministradorOracle
        Dim pObjgrilla As String = "EDITARAVANCEFISICO"
        Try
            objData = New AdministradorOracle
            objData.CreateInputOracle("EJEC_M", strEjec_M, 20)
            objData.CreateInputOracle("M1", strM1, 20)
            objData.CreateInputOracle("F1", F1, 20)
            objData.CreateInputOracle("F2", F2, 20)
            objData.CreateInputOracle("F3", F3, 20)
            objData.CreateInputOracle("F4", F4, 20)
            objData.CreateInputOracle("M2", strM2, 20)
            objData.CreateInputOracle("M3", strM3, 20)
            objData.CreateInputOracle("M4", strM4, 20)
            objData.CreateInputOracle("OB", OB, 2000)
            objData.CreateInputOracle("E", E, 1)
            objData.CreateInputOracle("VERSION", strVersion, 1)
            objData.CreateInputOracle("IDPOAF", strCodigo, 50)

            objData.ExecuteOracle_NonQuery("EDITARAVANCEFISICO", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try

    End Sub 

End Class
